package com.quanyan.club.mapper;

import com.quanyan.club.entity.db.TbSignUser;
import com.quanyan.club.entity.vo.req.admin.ReqClubQuery;
import com.quanyan.club.entity.vo.resp.RespSearchActivity;
import com.quanyan.club.entity.db.TbActivityPoster;
import com.quanyan.club.entity.db.TbClubActivity;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Author Hugo.Wwg
 * @Since 2016-06-17
 */
public interface ClubActivityMapper {

    /**
     * 设置已经报名的总人数
     */
    int updateAlreadySignTotalNum(@Param("map") Map<String, Object> paraMap);

    /**
     * 锁定已经报名的总人数
     */
    int updateAlreadyLockSignTotalNum(@Param("map") Map<String, Object> paraMap);

    int updateAlreadyLockSignTotalNumNotZero(@Param("map") Map<String, Object> paraMap);

    Integer selectUidByActivityId(Integer activityId);

    /**
     * 设置已经报名的男生人数
     */
    int updateAlreadySignManNum(@Param("map") Map<String, Object> paraMap);

    /**
     * 设置已经报名的女生人数
     */
    int updateAlreadySignWomenNum(@Param("map") Map<String, Object> paraMap);

    /**
     * 扣除俱乐部成员账户余额
     */
    int deductionPersonClubAccountBalance(@Param("map") Map<String, Object> paraMap);

    /**
     * 增加俱乐部成员账户余额
     */
    int addPersonClubAccountBalance(@Param("map") Map<String, Object> paraMap);

    /**
     * 扣除人数
     */
    int deductionSignTotalNum(@Param("map") Map<String, Object> paraMap);

    /**
     * 恢复锁定总人数库存
     */
    int recoveryLockSignTotalNum(@Param("map") Map<String, Object> paraMap);



    /**
     * 恢复锁定男生人数库存
     */
    int recoverySignManNum(@Param("map") Map<String, Object> paraMap);

    /**
     * 恢复锁定女生人数库存
     */
    int recoverySignWomenNum(@Param("map") Map<String, Object> paraMap);

    /**
     * 增加线上俱乐部金额
     */
    int incrementOnlineClubAccount(@Param("map") Map<String, Object> paraMap);

    /**
     * 扣除线上俱乐部金额
     */
    int reduceOnlineClubAccount(@Param("map") Map<String, Object> paraMap);

    /**
     * 增加线下俱乐部金额
     */
    int incrementOfflineClubAccount(@Param("map") Map<String, Object> paraMap);

    List<TbClubActivity> selectRecommends(@Param("cityId") Integer cityId, @Param("categoryId") Integer categoryId,
                                          @Param("start") Integer start, @Param("size") Integer size);

    List<Integer> selectActivityIdByStatus(@Param("activityStatus") float activityStatus,
                                         @Param("start") Integer start, @Param("size") Integer size);
    int countActivityIdByStatus(@Param("activityStatus") float activityStatus);
    List<Integer> selectActivityByUid(@Param("uid") Integer uid, @Param("categoryId") Integer categoryId);

    int updateStatusByActivityId(@Param("activityStatus") float activityStatus, @Param("list") List<Integer> activityIds);

    int countRecommends(@Param("cityId") Integer cityId, @Param("categoryId") Integer category);

    int countMember(Integer clubId);

    List<Integer> selectEffectiveActivityByClub(Integer clubId);

    List<Integer> selectEffectiveActivityByClubInTime(Integer clubId);

    List<Integer> selectEffectiveActivityByQueryTime(Integer clubId,Date startQueryTime,Date endQueryTime);

    List<List<Integer>> selectEffectiveActivityByEveryDay(Integer clubId,Date trendStartTime,Date trendEndTime);

    Integer selectClubByActivityId(Integer activityId);

    int batchInsertPoster(List<TbActivityPoster> posters);

    List<TbActivityPoster> selectActivityPostByClub(@Param("map") Map<String, Object> map);

    int countActivityPostByClub(@Param("map") Map<String, Object> map);

    //俱乐部活动列表专用
    List<TbClubActivity> selectTbActivityList(@Param("map") Map<String, Object> map);

    List<TbClubActivity> selectTbActivityByUid(@Param("map") Map<String, Object> map);

    int countTbActivityList(@Param("map") Map<String, Object> map);

    //返回与我相关的活动列表，包括创建的，管理的，加入的，开始时间在今天范围内，并且还没结束的活动
    List<Integer> selectEffectiveActivityByClubIds(@Param("list") List<Integer> clubsIds,
            @Param("dateBegin") Date dayBeginsec, @Param("dateEnd") Date dayEndsec,
            @Param("cityId") Integer cityId, @Param("districtId") Integer districtId,
                                                   @Param("categoryId") Integer categoryId);

    //查询是否有需要结算的订单
    List<TbSignUser> selectNeedSettleOrderOnline(@Param("activityId") Integer activityId);

    //简单获取(activity)的id, name, fee_type
    List<Map<String, Object>> selectActivityNameFeeTypeByIds(@Param("list") List<Integer> activityIds);

    //查询所有需要结算的报名人员

    Integer countUnsettleActivityNum(@Param("clubId") int clubId);

    List<Integer> selectClubPlaceUnBind(@Param("pageStart") int pageStart,
                                        @Param("pageSize") int pageSize);

    int countClubPlaceUnBind();

    List<Integer> selectActivityIdByStatusRepaire();

    List<Integer> selectPlaceActivity(@Param("placeId") int placeId,
                                      @Param("pageStart") int pageStart,
                                      @Param("pageSize") int pageSize, @Param("categoryId") int categoryId);

    int countPlaceActivity(@Param("placeId") int placeId, @Param("categoryId") int categoryId);
}
